package com.ytc.util;

import com.ytc.model.Book;
import com.ytc.model.Booklist;

import java.util.Collections;
import java.util.Comparator;

/**
 * 详细介绍类情况.
 *
 * @ClassName BookSortUtil
 * @Author zk
 * @Date 2023/1/12
 * @Version 1.0
 */
public class BookSortUtil {
    public static void bookSort(Booklist book){
        Collections.sort(book.getBooks(), new Comparator<Book>() {
            @Override
            public int compare(Book o1, Book o2) {
                //章节序号升序排序
                if(o1.getBchapternum() > o2.getBchapternum()){
                    return 1;
                }
                if(o1.getBchapternum() == o2.getBchapternum()){
                    return 0;
                }
                return -1;
            }
        });
    }
}
